package com.glsc.ngateway.common.base.domain.mysql.opmanagemain.document;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.DateSerializer;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.glsc.ngateway.common.api.common.enums.DictConstant;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * @author liwei
 * 通用上传文件
 */
@Data
@Entity
@Table(name = "t_document_info")
@org.hibernate.annotations.Table(appliesTo = "t_document_info", comment = "通用上传文件")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class DocumentInfo implements Serializable {
    private static final long serialVersionUID = -365607141666782133L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "doc_id")
    private Integer docId;

    @Column(name = "file_name", columnDefinition = "varchar(1024) COMMENT '档案文件名称'")
    @ApiModelProperty(value = "档案文件名称")
    private String fileName;

    @Column(name = "file_path", columnDefinition = "varchar(1024) COMMENT '文件存储路径'")
    @ApiModelProperty(value = "文件存储路径")
    private String filePath;

    @Column(name = "file_size", columnDefinition = "INT COMMENT '档案文件字节数'")
    @ApiModelProperty(value = "档案文件字节数")
    private Integer fileSize;

    @Column(name = "doc_type", columnDefinition = "varchar(10) COMMENT '文件类型，1 档案中心文件'")
    @ApiModelProperty(value = "档案类别，字典： am_prod_doc_type")
    private String docType;

    @Column(name = "file_desc", columnDefinition = "varchar(200) COMMENT '文件说明信息'")
    @ApiModelProperty(value = "文件说明信息")
    private String fileDesc;

    @ApiModelProperty(value = "文件md5校验码")
    @Column(name = "checksum", columnDefinition = "varchar(1024) COMMENT '文件md5校验码'")
    private String checksum;

    @ApiModelProperty(value = "删除状态，字典 YesNo:（N=未删除(默认) Y=已删除)")
    @Column(name = "deleted", columnDefinition = "varchar(20) default 'N' COMMENT '日删除状态，字典 yesno （N=否(默认) Y=是)'")
    protected String deleted= DictConstant.NO;

    //创建时间
    @Column(name = "create_time",updatable = false)
    @org.hibernate.annotations.CreationTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = DateSerializer.class)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @ApiModelProperty(value = "创建人ID")
    @Column(name = "create_operator", columnDefinition = "varchar(20) COMMENT '创建人ID'")
    protected String createOperator;

    @ApiModelProperty(value = "创建人姓名")
    @Column(name = "create_operator_name", columnDefinition = "varchar(20) COMMENT '创建人姓名'")
    protected String createOperatorName;

    @ApiModelProperty(value = "操作来源")
    @Column(name = "op_source", columnDefinition = "varchar(32) COMMENT '操作来源'")
    protected String opSource;

    @ApiModelProperty(value = "操作动作(增加、修改)")
    @Column(name = "op_action", columnDefinition = "varchar(32) COMMENT '操作动作(增加、修改)'")
    protected String opAction;

    @ApiModelProperty(value = "操作人员ID")
    @Column(name = "op_operator", columnDefinition = "varchar(20) COMMENT '操作人员ID'")
    protected String opOperator;

    @ApiModelProperty(value = "操作时间 yyyy-MM-dd HH:mm:ss")
    @Column(name = "op_time", columnDefinition = "datetime comment '操作时间'")
    @org.hibernate.annotations.UpdateTimestamp
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    protected LocalDateTime opTime;

}
